const Base = require('../base.js');

module.exports = class extends Base {
  async indexAction() {
    var _data = {};
    if(this.isGet) _data = this.get()
    if(this.isPost) _data = this.post()
    console.log(_data)
    console.log(_data.phone)
    var num = '';
    for(var i=0;i<6;i++){
      num+=Math.floor(Math.random()*10)
    }
    console.log('生成的验证码' + num)
    /**
     * 发送验证码 操作
     */
    var data = {
      code: num,
      time: Date.now() + think.ms('10m'),
      phone: parseInt(_data.phone)
    }
    console.log(data)
    var token = await this.session('code', data)
    this.json({
      token,
      code: num // 临时的 正式环境删除
    })
  }
};
